/**
 * @description 深复制
 * @param {Object} source 复制对象
 * @returns {Object}
 */
export function deepClone(source) {
	if (!source && typeof source !== 'object') {
		throw new Error('error arguments', 'shallowClone')
	}
	const targetObj = source.constructor === Array ? [] : {}
	for (const keys in source) {
		if (source.hasOwnProperty(keys)) {
			if (source[keys] && typeof source[keys] === 'object') {
				targetObj[keys] = source[keys].constructor === Array ? [] : {}
				targetObj[keys] = deepClone(source[keys])
			} else {
				targetObj[keys] = source[keys]
			}
		}
	}
	return targetObj
}
/**
 * @description 生成uuid
 * @returns {string}
 */
export function getUuid() {
	return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
		let r = Math.random() * 16 | 0
		let v = c === 'x' ? r : (r & 0x3 | 0x8)
		return v.toString(16)
	})
}
